package com.zhangliuliu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhangliuliu.bean.MedicamentBean;
import com.zhangliuliu.service.MedicService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("medic")

public class medicController {
    @Resource
    private MedicService medicService;

    @RequestMapping("cutAll")
    @ResponseBody
    IPage<MedicamentBean> cutAll(@RequestParam(value = "pageNo",defaultValue = "1") int pageNo,
                                 @RequestParam(value = "pageSize",defaultValue = "4") int pageSize){
       return medicService.cutAll(pageNo,pageSize);
    }
    @RequestMapping("add")
    @ResponseBody
    void add(MedicamentBean medicamentBean){
        medicService.add(medicamentBean);
    }
    IPage<MedicamentBean>cutByItem(@RequestParam(value = "pageNo",defaultValue = "1") int pageNo,
                                   @RequestParam(value = "pageSize",defaultValue = "4") int pageSize,
                                   @RequestParam("name") String name,
                                   @RequestParam("prevent") String prevent,
                                   @RequestParam("type") String type){
       return medicService.cutByItem(pageNo,pageSize,name,prevent,type);
    }
}
